package com.example.fx.search

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.example.base.entity.GoodsEntityResult
import com.example.base.mvvm.BaseViewModel
import kotlinx.coroutines.launch

class SearchViewModel:BaseViewModel() {
    val searchSuccess = MutableLiveData<GoodsEntityResult>()
    val searchFail = MutableLiveData<String>()

    fun search(keyword:String,page:Int,limit:Int){
        viewModelScope.launch {
            try {
                searchSuccess.value = apiService.search(keyword, page, limit)
            }catch (e:Exception){
                searchFail.value = e.message
            }
        }
    }
}